import Vue from 'vue'
import App from './App.vue'

import axios from './http/http.js'
import VueResource from 'vue-resource'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import echarts from 'echarts'
import './reset.css'
import './global.css'
import './element.css'
import router from './routes.js'
import Print from './component/print.js'
import moment from 'moment'
import VueAMap from 'vue-amap'
import jquery from 'jquery'
import BaiduMap from 'vue-baidu-map'
import { Area } from 'vant';
import md5 from 'js-md5';
import XLSX from 'xlsx';
import VueScrollspy from 'vue2-scrollspy'


Vue.use(VueScrollspy, {
  animation: 'fade', // 动画效果，可选值：'fade'、'slide'、'convex'、'concave'、'none'
  duration: 1000, // 动画持续时间，单位：毫秒
})
import preventReClick from './component/preventReClick' //防多次点击，重复提交
 
Vue.use(Area)
Vue.use(BaiduMap,{
    ak:'5sMrBduac1Ru8Fb5EXABNaV3WRREL8Z1'		//使用申请的百度地图秘钥
})

// 设置点击间隔
Vue.directive('preventClick', {
  inserted (el) {
    el.addEventListener('click', () => {
      if (!el.disabled) {
        el.disabled = true
        setTimeout(() => {
          el.disabled = false
        }, 3000)
      }
    })
  }
})

Vue.use(VueAMap)
Vue.use(ElementUI)
Vue.use(VueResource)
Vue.use(Print)

import store from './store/store.js'

Vue.prototype.$axios = axios;
Vue.prototype.$echarts = echarts;
Vue.prototype.jQuery = jquery;
Vue.prototype.linkTo = (path,query) => {
	router.push({
		path,query
	})
}

Vue.prototype.$md5 = md5;

Vue.prototype.getBase64Image = (img) => {
    const myPromise = new Promise((resolve, reject) => {
        img.onload = () => { // onload 为异步事件
            var canvas = document.createElement("canvas");
            var width = img.naturalWidth || img.width;
            var height = img.naturalHeight || img.height;
            canvas.width = width;
            canvas.height = height;
            var ctx = canvas.getContext("2d");
            ctx.drawImage(img, 0, 0, width, height); // 绘制图像
            var ext = img.src.substring(img.src.lastIndexOf(".") + 1).toLowerCase(); // 图片格式
            var dataURL = canvas.toDataURL("image/" + ext); // 包含图片展示的 data URI
            if (dataURL) {
                resolve(dataURL);
            } else {
                reject("参数错误,请传入一个img")
            }

        }

    })

    return myPromise;
}





Vue.filter('formatDate', res => {
  return moment(res).format('YYYY-MM-DD HH:mm:ss')
})
/* 电话招聘系统-标注过滤器 */
Vue.filter('arrange',res => {
	return res=='1'?'已安排':'等待安排'
})
/* 电话招聘系统-字符串截取,超过二十个字后面变成'...' */
Vue.filter('intercept',res => {
	// return res.length > 20?res.substring(0,20)+'...':res;
})
/* 电话招聘系统-项目中止 */
Vue.filter('suspendStatus',res => {
	return res == 1?'已中止':'中止';
})

/* 返回值非空处理 */
Vue.filter('empty',res => {
	return (res == '' || res == undefined || res == null)?'-':res;
})

// Vue.config.debug = true; //开启错误提示
new Vue({
  router,
  store,
  el: '#APP',
  render: h => h(App)
})
